<?php
namespace app\admin\model;
use think\Model;
use think\Db;
class JoinTableModel extends Model
{

    /**
     * 三表联查
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getThreeJoinList($tbale,$tbale2,$tbale3,$condition,$condition1,$where,$field,$order)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->select();
        return $list;
    }

    /**
     * 三表联查一条信息
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getThreeJoinInfo($tbale,$tbale2,$tbale3,$condition,$condition1,$where,$field,$order)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->find();
        return $list;
    }

    /**
     * 三表联查带分页
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getThreeJoinListPage($tbale,$tbale2,$tbale3,$condition,$condition1,$where,$field,$order,$page,$nums)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->page($page,$nums)
            ->select();
        return $list;
    }

    /**
     * 三表联查查询总条数
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getThreeJoinCount($tbale,$tbale2,$tbale3,$condition,$condition1,$where,$count)
    {
        $total = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->where($where)
            ->count($count);
        return $total;
    }

    /**
     * 三表联查带分页带分组
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getThreeJoinListPageGroup($tbale,$tbale2,$tbale3,$condition,$condition1,$where,$field,$order,$page,$nums,$group)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->group($group)
            ->page($page,$nums)
            ->select();
        return $list;
    }

    /**
     * 三表联查查询总条数带分组
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getThreeJoinCountGroup($tbale,$tbale2,$tbale3,$condition,$condition1,$where,$count,$group)
    {
        $total = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->where($where)
            ->group($group)
            ->count($count);
        return $total;
    }


    /**
     * 两表联查查询总条数
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getTwoJoinTotal($tbale,$tbale2,$condition,$where,$count)
    {
        $total = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->where($where)
            ->count($count);
        return $total;
    }

    /**
     * 两表联查
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getTwoJoinList($tbale,$tbale2,$condition,$where,$field,$order)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->select();
        return $list;
    }

    /**
     * 两表联查带分页
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getTwoJoinListPage($tbale,$tbale2,$condition,$where,$field,$order,$page,$nums)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->page($page,$nums)
            ->select();
        return $list;
    }

    /**
     * 两表联查一条信息
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getTwoJoinFind($tbale,$tbale2,$condition,$where,$field,$order)
    {
        $info = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->find();
        return $info;
    }


    /**
     * 五表联查
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getFiveJoinList($tbale,$tbale2,$tbale3,$tbale4,$tbale5,$condition,$condition1,$condition2,$condition3,$where,$field,$order)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->join([$tbale4 => 'd'],$condition2,'LEFT')
            ->join([$tbale5 => 'e'],$condition3,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->select();
        return $list;
    }



    /**
     * 五表联查带分页
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getFiveJoinListPage($tbale,$tbale2,$tbale3,$tbale4,$tbale5,$condition,$condition1,$condition2,$condition3,$where,$field,$order,$page,$nums)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->join([$tbale4 => 'd'],$condition2,'LEFT')
            ->join([$tbale5 => 'e'],$condition3,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->page($page,$nums)
            ->select();
        return $list;
    }

    /**
     * 五表联查查询总条数
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getFiveJoinCount($tbale,$tbale2,$tbale3,$tbale4,$tbale5,$condition,$condition1,$condition2,$condition3,$where,$count)
    {
        $total = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->join([$tbale4 => 'd'],$condition2,'LEFT')
            ->join([$tbale5 => 'e'],$condition3,'LEFT')
            ->where($where)
            ->count($count);
        return $total;
    }


    /**
     * 五表联查一条详情
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getFiveJoinFind($tbale,$tbale2,$tbale3,$tbale4,$tbale5,$condition,$condition1,$condition2,$condition3,$where,$field,$order)
    {
        $info = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->join([$tbale4 => 'd'],$condition2,'LEFT')
            ->join([$tbale5 => 'e'],$condition3,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->find();
        return $info;
    }


    /**
     * 两表联查带分页带分组
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getTwoJoinListGroupPage($tbale,$tbale2,$condition,$where,$group,$field,$order,$page,$nums)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->page($page,$nums)
            ->group($group)
            ->select();
        return $list;
    }


    /**
     * 两表联查总数带分组
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getTwoJoinGroupTotal($tbale,$tbale2,$condition,$where,$group,$count){
        $total = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->where($where)
            ->group($group)
            ->count($count);
        return $total;
    }


    /**
     * 三表联查带分页带分组
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getThreeJoinListGroupPage($tbale,$tbale2,$tbale3,$condition,$condition1,$where,$group,$field,$order,$page,$nums)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->group($group)
            ->page($page,$nums)
            ->select();
        return $list;
    }

    /**
     * 三表联查查询总条数带分组
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getThreeJoinGroupCount($tbale,$tbale2,$tbale3,$condition,$condition1,$where,$group,$count)
    {
        $total = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->where($where)
            ->group($group)
            ->count($count);
        return $total;
    }

    /**
     * 六表联查
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getSexJoinList($tbale,$tbale2,$tbale3,$tbale4,$tbale5,$tbale6,$condition,$condition1,$condition2,$condition3,$condition4,$where,$field,$order)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->join([$tbale4 => 'd'],$condition2,'LEFT')
            ->join([$tbale5 => 'e'],$condition3,'LEFT')
            ->join([$tbale6 => 'f'],$condition4,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->select();
        return $list;
    }

    /**
     * 四表联查
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getFourJoinList($tbale,$tbale2,$tbale3,$tbale4,$condition,$condition1,$condition2,$where,$field,$order)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->join([$tbale4 => 'd'],$condition2,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->select();
        return $list;
    }


    /**
     * 四表联查带分页
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getFourJoinListPage($tbale,$tbale2,$tbale3,$tbale4,$condition,$condition1,$condition2,$where,$field,$order,$page,$nums)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->join([$tbale4 => 'd'],$condition2,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->page($page,$nums)
            ->select();
        return $list;
    }

    /**
     * 四表联查查询总条数
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getFourJoinCount($tbale,$tbale2,$tbale3,$tbale4,$condition,$condition1,$condition2,$where,$count)
    {
        $total = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->join([$tbale4 => 'd'],$condition2,'LEFT')
            ->where($where)
            ->count($count);
        return $total;
    }




    /**
     * 六表联查带分页
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getSexJoinListPage($tbale,$tbale2,$tbale3,$tbale4,$tbale5,$tbale6,$condition,$condition1,$condition2,$condition3,$condition4,$where,$field,$order,$page,$nums)
    {
        $list = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->join([$tbale4 => 'd'],$condition2,'LEFT')
            ->join([$tbale5 => 'e'],$condition3,'LEFT')
            ->join([$tbale6 => 'f'],$condition4,'LEFT')
            ->where($where)
            ->field($field)
            ->order($order)
            ->page($page,$nums)
            ->select();
        return $list;
    }

    /**
     * 六表联查查询总条数
     * User:@hang
     * Date:2024-03-30 12:06
     */
    public function getSexJoinCount($tbale,$tbale2,$tbale3,$tbale4,$tbale5,$tbale6,$condition,$condition1,$condition2,$condition3,$condition4,$where,$count)
    {
        $total = Db::table($tbale)
            ->alias('a')
            ->join([$tbale2 => 'b'],$condition,'LEFT')
            ->join([$tbale3 => 'c'],$condition1,'LEFT')
            ->join([$tbale4 => 'd'],$condition2,'LEFT')
            ->join([$tbale5 => 'e'],$condition3,'LEFT')
            ->join([$tbale6 => 'f'],$condition4,'LEFT')
            ->where($where)
            ->count($count);
        return $total;
    }


}